<template>
  <u-container-layout>
    <zlrt-table :p="ctx">
      <template #before>
        <zlrt-search :p="ctx">
        </zlrt-search>
        <div class="tool-bar">
          <el-button type="danger" v-hasPermit="['tms:vehicle:del']" icon="Delete" :disabled="!ctx.selected.length"
            @click="ctx.batchDelete()">
            批量删除
          </el-button>
          <span style="float:right">
            <el-button type="success" v-hasPermit="['tms:vehicle:list']" :loading="ctx.exportLoading" icon="Download"
              @click="ctx.export()">
              导出
            </el-button>
            <el-button type="primary" v-hasPermit="['tms:vehicle:save']" icon="Plus" @click="ctx.showEdit()">
              添加
            </el-button>
          </span>
        </div>
      </template>
      <template v-slot:drivingLicenseImg="scope">
        <el-popover placement="left" trigger="hover" :width="300">
          <template #reference>
            <img :src="scope.row.drivingLicenseImg" style="height: 40px;">
          </template>
          <img :src="scope.row.drivingLicenseImg" style="width: 300px;">
        </el-popover>
      </template>
      <template v-slot:vehicleLicenseImg="scope">
        <el-popover placement="left" trigger="hover" :width="300">
          <template #reference>
            <img :src="scope.row.vehicleLicenseImg" style="height: 40px;">
          </template>
          <img :src="scope.row.vehicleLicenseImg" style="width: 300px;">
        </el-popover>
      </template>
      <template v-slot:insuranceImg="scope">
        <el-popover placement="left" trigger="hover" :width="300">
          <template #reference>
            <img :src="scope.row.insuranceImg" style="height: 40px;">
          </template>
          <img :src="scope.row.insuranceImg" style="width: 300px;">
        </el-popover>
      </template>
      <template #operation="scope">
        <el-button type="primary" v-hasPermit="['tms:vehicle:save']" link size="small" icon="Edit"
          @click="ctx.showEdit(scope.row)">
          编辑
        </el-button>
        <el-button v-hasPermit="['tms:vehicle:del']" type="danger" link size="small" icon="Delete"
          @click="ctx.del(scope.row.id)">
          删除
        </el-button>
      </template>
      <template #after>
        <el-dialog v-model="ctx.editVisible" :title="ctx.editAction + ctx.title" width="600px" append-to-body
          :close-on-click-modal="false" @close="ctx.closeEdit()">
          <el-form :ref="(e) => ctx.formRef = e" :model="ctx.editData" :rules="ctx.rules" v-loading="ctx.editLoading"
            label-width="120px" class="demo-ruleForm">
            <el-form-item label="车牌号" prop="plateNumber">
              <el-input v-model="ctx.editData.plateNumber" placeholder="请输入车牌号" />
            </el-form-item>
            <el-form-item label="车主" prop="driverName">
              <el-input v-model="ctx.editData.driverName" placeholder="请输入车主" />
            </el-form-item>
            <el-form-item label="联系方式" prop="driverTel">
              <el-input v-model="ctx.editData.driverTel" placeholder="请输入联系方式" />
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="ctx.editVisible = false">取消</el-button>
              <el-button type="primary" @click="ctx.save()">确定</el-button>
            </span>
          </template>
        </el-dialog>
      </template>
    </zlrt-table>
  </u-container-layout>
</template>

<script lang="ts" src="./driver" />

<style lang="scss" scoped>

</style>
